﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Export.Ui.Pages" x:Class="Export.Ui.Pages.Home" 
             mc:Ignorable="d" 
             DataContext="{Binding Main, Source={StaticResource ViewModelLocator}}"
             d:DesignHeight="300" d:DesignWidth="1000">
    <Grid Style="{StaticResource ContentRoot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <DataGrid  x:Name="queuesGrid"
                           SelectionMode="Single"
                            ItemsSource="{Binding Queues}"
                            SelectedItem="{Binding SelectedQueue}"
                            SelectedIndex="{Binding SelectedQueueIndex}"
                            AutoGenerateColumns="False"
                            CanUserSortColumns="True"
                            CanUserAddRows="False"
                           Grid.Column="0" Grid.Row="1"
                           Grid.ColumnSpan="2"
                          >
            <DataGrid.Columns>
                <!--<DataGridTextColumn Binding="{Binding Priority}" ClipboardContentBinding="{x:Null}" Header="Priority" IsReadOnly="True" />-->
                <DataGridTextColumn Binding="{Binding ProductCode}" ClipboardContentBinding="{x:Null}" Header="Product No." IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding ProductName}" ClipboardContentBinding="{x:Null}" Header="Product Name" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding RefOrderNo}" ClipboardContentBinding="{x:Null}" Header="Order No." IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding OriginalQty}" ClipboardContentBinding="{x:Null}" Header="OriginalQty" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding Qty}" ClipboardContentBinding="{x:Null}" Header="Quantity" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding PlantCode}" ClipboardContentBinding="{x:Null}" Header="PlantCode" IsReadOnly="False" />
                <DataGridTextColumn Binding="{Binding Rate}"  ClipboardContentBinding="{x:Null}" Header="%" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding ValidFrom}" ClipboardContentBinding="{x:Null}" Header="ValidFrom" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding ValidTo}" ClipboardContentBinding="{x:Null}" Header="ValidTo" IsReadOnly="True" />
                <DataGridCheckBoxColumn Binding="{Binding IsActive}" ClipboardContentBinding="{x:Null}" Header="Active" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding Date}" ClipboardContentBinding="{x:Null}" Header="Order Date"/>
            </DataGrid.Columns>
        </DataGrid>



        <Button  Visibility="Collapsed" Grid.Column="2" Grid.Row="2"  Content="Up" CommandParameter="{Binding ElementName=queuesGrid, Path=SelectedIndex}" Command="{Binding MoveQueueUpCommand}" Margin="8,0,0,0" Cursor="Hand"  >
            <Button.Background>
                <ImageBrush  ImageSource="C:\export\Resource\Up.ico" Stretch="Uniform" TileMode="None" AlignmentX="Left" >

                </ImageBrush>
            </Button.Background>

        </Button>
        <Button Visibility="Collapsed" Grid.Column="2" Grid.Row="3"  Content="Down" CommandParameter="{Binding ElementName=queuesGrid, Path=SelectedIndex}" Command="{Binding MoveQueueDownCommand}" Margin="8,0,0,0" Cursor="Hand" >
            <Button.Background>
                <ImageBrush  ImageSource="C:\export\Resource\down.ico" Stretch="Uniform" TileMode="None" AlignmentX="Left" >

                </ImageBrush>
            </Button.Background>
        </Button>
        <Button Grid.Column="0" Content="Disable" CommandParameter="{Binding ElementName=queuesGrid, Path=SelectedIndex}" Command="{Binding DisableQueueCommand}" Width="75" Cursor="Hand" />
        <Button Grid.Column="1" HorizontalAlignment="Left" Content="Enable" CommandParameter="{Binding SelectedIndex, ElementName=queuesGrid}" Command="{Binding EnableQueueCommand}"  Width="75" Cursor="Hand" Margin="8,0,0,0"  />
        <Button Grid.Column="1" HorizontalAlignment="Right" Content="Delete Queue" CommandParameter="{Binding ElementName=queuesGrid, Path=SelectedIndex}" Command="{Binding DeleteQueueCommand}" Cursor="Hand" />
        <Button Grid.Column="1" HorizontalAlignment="Center" Content="Test change plant" CommandParameter="{Binding ElementName=queuesGrid, Path=SelectedIndex}" Command="{Binding ChangePlantCommand}"  Cursor="Hand" />
    </Grid>
</UserControl>
